<?php
/**
 *
 * 千禾API异常类
 * @author Zhang Xingliang
 *
 */
class QHException extends Exception {
	public function errorMessage()
	{
		return $this->getMessage();
	}

    protected static $ErrorMsg = array(
        'app_key'=>'缺少必要参数，app_key',
        'user_id'=>'缺少必要参数，user_id',
        'notify_url'=>'缺少必要参数，notify_url',
    );

	/*
	 * 请求参数空值校验
	 *
	 * @author Zhang Xingliang
	 * @param $entity
	 * @param $field
	 **/
	public static function validateParam($entity,$field){
        if ($entity->IsEmpty($field)) {
            throw new QHException(self::$ErrorMsg[$field]);
        }
    }

    /*
     * 抛异常
     *
     * @author Zhang Xingliang
     * @param $error
     **/
    public static function ThrowQHException($error){
        throw new QHException($error);
    }

}
